﻿@model KL.Store.Web.Models.BannerMenuModel
@using KL.Store.Core
@{
    ViewBag.Title = "Banner İşlemleri";
    Layout = "~/Views/Shared/_LayoutReportPanel.cshtml";
}
<div id="processResult"></div>
<div id="bannerEdit" class="col-sm-12 col-md-10 right first last">
    <div class="bannerEditMenu col-xs-12 col-sm-12 col-md-3 col-lg-3 first last" id="bannerMenu">
        <div id="bannerEditMenuPlaceholder">
            @{Html.RenderAction("BannerListMenu", "ReportPanel");}
        </div>
        <div class="clearfix"></div>
    </div>
    <div class="bannerEditRight col-xs-12 col-sm-12 col-md-9 col-lg-9 last" id="bannerEditRight">
        <div id="bannerEditContent"></div>
    </div>
</div>
<script type="text/javascript">
    function GetBanner(bannerid)
    {
        //alert(bannerid);
        loadingMsg();
        $('#bannerEditContent').load('/ReportPanel/BannerGet', { BannerId: bannerid }, function ()
        {
            $('.selectedBanner').removeClass('selectedBanner');
            var editor = CKEDITOR.instances['Banner_Html'];
            if (editor) { editor.destroy(true); }
            CKEDITOR.replace('Banner_Html');

            AjaxImageUploadJS('bannerEditRight', 'BannerUpload', 'BannerDrop', 'BANNER RESİMİ olarak yüklenecektir, emin misiniz?');
            AjaxImageUploadJS('bannerEditRight', 'BannerThumbUpload', 'BannerThumbDrop', 'BANNER THUMB RESİMİ olarak yüklenecektir, emin misiniz?');
            $('.datetimepicker').datetimepicker({
                format: "d.m.Y H:i:s"
            });

            $('#Banner' + bannerid).addClass('selectedBanner');
            $('.loadingMsg').remove();
        });
    }
    function ImageUploadOk()
    {
        var selectedItem = $('.selectedBanner');
        var bannerid = selectedItem.data('id');
        GetBanner(bannerid);
    }
    function bannerGuncellendi(bannerid)
    {
        $('#processResult').show(0).html('<div class="bg-info"><p><i class="fa fa-info-circle"></i>&nbsp;Bilgiler Kaydedildi</p></div>').delay(5000).hide(0);
        $('#bannerEditMenuPlaceholder').load('/ReportPanel/BannerListMenu', { BannerId: bannerid });
    }
    function bannerEklendi(bannerid)
    {
        GetBanner(bannerid);
        $('#bannerEditMenuPlaceholder').load('/ReportPanel/BannerListMenu', { BannerId: bannerid });
        $('#processResult').show(0).html('<div class="bg-info"><p><i class="fa fa-info-circle"></i>&nbsp;Banner Eklendi</p></div>').delay(5000).hide(0);
    }
    function bannerSil(bannerid)
    {
        if (confirm('Banner\'ı silmek istediğinizden emin misiniz?'))
        {
            loadingMsg();
            $.post('/ReportPanel/BannerDelete', { BannerId: bannerid }, function (result)
            {
                if (result == "success")
                {
                    loadingMsg2('Resimler Siliniyor.');
                    $.post('/Upload/DeleteImage', { Id: bannerid, Password: '@(Model.Password)', ImageType: 'banner', ImageNo: '0' }, function (delresult)
                    {
                        if (delresult == 'Resim Silindi.')
                        {
                            $.post('/Upload/DeleteImage', { Id: bannerid, Password: '@(Model.Password)', ImageType: 'banner-thumb', ImageNo: '0' }, function (delresult2)
                            {
                                $('#bannerEditMenuPlaceholder').load('/ReportPanel/BannerListMenu');
                                $('#processResult').show(0).html('<div class="bg-info"><p><i class="fa fa-info-circle"></i>&nbsp;Banner Silindi</p></div>').delay(5000).hide(0);
                                $('#bannerEditContent').html('');
                            });
                        }
                    });
                }
                else
                {
                    hataMesaji('Banner silinirken bir hata oluştu.');
                }
            });
        }
    }
</script>
